package com.cxrj.zhsq.propertyManage.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cxrj.zhsq.propertyManage.entity.WorkOrder;
import com.cxrj.zhsq.propertyManage.service.WorkOrderService;

@Controller
@RequestMapping("/work_order")
public class WrokOrderController {
	
	@Resource
	private WorkOrderService workOrderService;
	
	/**
	 * 新增或修改工单
	 * @param workOrder
	 * @return
	 */
	@RequestMapping("insertAndUpdateWorkOrder")
	@ResponseBody
	public Map<String, Object> insertAndUpdateWorkOrder(WorkOrder workOrder){
		return workOrderService.insertAndUpdateWorkOrder(workOrder);
	}
	/**
	 * 转工单操作
	 * @param workOrder
	 * @return
	 */
	@RequestMapping("insertWorkOrder")
	@ResponseBody
	public Map<String, Object> insertWorkOrder(WorkOrder workOrder){
		return workOrderService.insertWorkOrder(workOrder);
	}
	
	/**
	 * 工单查询
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "selectOrderPage", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> selectOrderPage(HttpServletRequest request,HttpServletResponse response){
		return workOrderService.selectOrderPage(request,response);
	}
	
	/**
	 * 根据Id查询
	 * @param appealId
	 * @return
	 */
	@RequestMapping(value = "selectById", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> selectById(String workOrderId){
		return workOrderService.selectById(workOrderId);
	}
	
	/**
	 * 处理工单
	 * @param workOrder
	 * @return
	 */
	@RequestMapping("updateWorkOrder")
	@ResponseBody
	public Map<String, Object> updateWorkOrder(WorkOrder workOrder){
		return workOrderService.updateWorkOrder(workOrder);
	}
	
	/**
	 * 删除工单
	 * @param workOrderId
	 * @return
	 */
	@RequestMapping("deleteWorkOrder")
	@ResponseBody
	public Map<String, Object> deleteWorkOrder(String workOrderId){
		return workOrderService.deleteWorkOrder(workOrderId);
	}

}
